<template>
  <NvCrud v-model:search-form="searchForm" :option :data @search="handleSearch" />
</template>

<script setup lang="tsx">
import type { NvCrudOption } from 'nv-crud'
import { NvCrud } from 'nv-crud'
import { ref } from 'vue'

const searchForm = ref({})
function handleSearch(done: () => void) {
  setTimeout(done, 1000)
}

const data = [{ name: '张三', sex: '男', age: 18 }]

const option: NvCrudOption = {
  rowActions: false,
  actionbar: false,
  toolbar: false,
  fields: {
    name: {
      title: '姓名',
      search: true,
    },
    sex: {
      title: '性别',
      type: 'select',
      dict: [{ label: '男', value: '男' }, { label: '女', value: '女' }],
      search: { formOrder: 2 },
    },
    age: {
      title: '年龄',
      type: 'number',
      search: { formOrder: 1 },
    },
    height: {
      title: '身高',
      type: 'number',
      search: true,
    },
  },
}
</script>
